This message box is generated using the following code:
Private Sub cmdSimple_Click()
MsgBox "Press the Enter key to continue..."
End Sub
When you click the second command button on the from, youll see a different message box appear (see Figure 11.2). Adding icons to the message box reinforces what youre trying to get across to the user.
Figure 11.2
A MsgBox with the critical icon.
The critical icon is used when a fatal type of error occurs. This message box is generated using the following code:
Private Sub cmdIcon_Click()
MsgBox "This is a message box with an icon", vbCritical
End Sub
When you click the third command button on the form, youll see the message box shown in Figure 11.3. Notice the use of the question mark icon in combination with the buttons that ask the user to respond.
Figure 11.3
A MsgBox with Yes and No buttons.
This message box is generated using the following code:
Private Sub cmdYesNo_Click() If MsgBox("Save the data?", vbQuestion + vbYesNo, _
"Save") = vbYes Then MsgBox "You pressed the Yes button"
Else
MsgBox "You pressed the No button"
End If
End Sub